package bayes;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;

import bayes.nodeTypes.Variable;

public class Evidence {

	private HashMap<Variable, Integer> _evidence;

	public HashMap<Variable, Integer> get_evidence() {
		return _evidence;
	}

	public Evidence() {
		this._evidence = new HashMap<Variable, Integer>();
	}
	public Evidence(Variable variable, Integer assignment){
		this();
		extend(variable, assignment);
	}

	public Evidence(Evidence other) {
		this._evidence = new HashMap<Variable, Integer>(other._evidence);	//TODO check if should be copied yesodi
	}

	public void extend(Variable variable, Integer assignment){
		this._evidence.put(variable, assignment);
	}

	public boolean contains(Variable variable) {
		return  _evidence.containsKey(variable);
	}

	public int getVarValue(Variable variable) {
		Integer ans = _evidence.get(variable);
		return ans;
	}
	@Override
	public String toString() {
		return "Evidence: " + this._evidence;
	}

	public Iterator<Entry<Variable, Integer>> iterator() {
		Iterator<Entry<Variable, Integer>> iterator = _evidence.entrySet().iterator();
		return iterator;
	}
}
